package de.dfki.dataSender;

import android.app.Activity;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.Window;
import android.view.WindowManager;

/**
 * Starts sending data to a server at {@code HOST:PORT}. 
 * 
 * @author Markus L�chtefeld (loechti)
 */
public class DataSenderActivity extends Activity {
	
	// TODO(norrielm): Allow the host and port to be set in the app or received via BT.
	private final String HOST = "10.0.1.25"; 
	private final int PORT = 1234;
	private SensorDataSender sender;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);  
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   
                                WindowManager.LayoutParams.FLAG_FULLSCREEN); 
        setContentView(R.layout.main);
        
		String deviceId = "IMEI:" + ((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
		  .getDeviceId();
		SensorManager sm = (SensorManager) getSystemService(SENSOR_SERVICE);
        sender = new SensorDataSender(this, sm, HOST, PORT, deviceId);
    }
    
    @Override
	protected void onResume() {
		super.onResume();
    	sender.onResume();
	}

    @Override
	protected void onStop() {
    	sender.onStop();
    	super.onStop();
	}
}